/**
 * https://leetcode-cn.com/problems/kth-node-from-end-of-list-lcci/
 * 返回第k个节点
 * @param head 
 * @param k 
 */
const kthToLast = (head: ListNode | null, k: number): number => {
    const arr: number[] = []

    // 放入数组中
    while (head !== null) {
        arr.push(head.val)
        head = head.next;
    }

    return arr[arr.length - k]
};